/*
* @author : TF-BJ-C064
* @creation : 2014-7-11 上午9:15:41
* @description : 
*
*/

package com.bean;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import net.sf.json.JSONObject;

/**
 * ParkOrder.extendInfo
 * <p>Title: ParkOrderExt</p>
 * <p>Description: </p>
 * <p>Company: www.teleframe.cn</p> 
 * @author	lijian
 * @date	2014-7-11
 */
public class ParkOrderExt implements java.io.Serializable {
	
	/* 
	 * 订单的扩展字段
	 * 	Json的格式表示:
	 * 		白天开始时间，白天结束时间，
	 * 		晚上开始时间，晚上结束时间，
	 * 		白天记时单位，晚上记时单位，
	 * 		白天单价，晚上单价
	 * 	Json {"dayEndTime":"","dayPrice":0,"dayStartTime":"","dayTimeUnit":0,"nightPrice":0,"nightStartTime":"","nightTimeUnit":0,"nightEndTime":""}
	 *  e.g:
	 *  	{"dayStartTime":"8:00","dayEndTime":"17:00","dayPrice":0.10,"dayTimeUnit":1, "nightStartTime":"20:00","nightEndTime":"23:00","nightPrice":0.05,"nightTimeUnit":1}
	 *  	{"dayStartTime":"8:00","dayEndTime":"18:00","dayPrice":0.02,"dayTimeUnit":0.5, "nightStartTime":"20:00","nightEndTime":"6:00","nightPrice":0.01,"nightTimeUnit":1}
	 *  	{"dayStartTime":"9:00","dayEndTime":"17:00","dayPrice":0.03,"dayTimeUnit":1, "nightStartTime":"20:00","nightEndTime":"6:00","nightPrice":0,"nightTimeUnit":1}
	 */
	
	/** serialVersionUID*/
	private static final long serialVersionUID = 3424738709042288478L;
	
	private String dayStartTime;//白天开始时间(hh:mm)
	private String dayEndTime;//白天结束时间(hh:mm)
	private String nightStartTime;//晚上开始时间(hh:mm)
	private String nightEndTime;//晚上结束时间(hh:mm)

	private double dayTimeUnit = 0;//白天记时单位(小时)
	private double nightTimeUnit = 0;//晚上记时单位(小时)
	private double dayPrice = 0;//白天单价(元)
	private double nightPrice = 0;//晚上单价(元)
	
	int ucDayStartHour; 	//白天开始计费--时
	int ucDayStartMinute   ;	//白天开始计费--分
	int ucDayStopHour ;			//白天结束计费--时
	int ucDayStopMinute ;		//白天结束计费--分
	
	int ucNightStartHour;		//夜晚开始计费--时
	int ucNightStartMinute;		//夜晚开始计费--分
	int ucNightStopHour;		//夜晚结束计费--时
	int ucNightStopMinute;		//夜晚结束计费--分
	
	double nGratuity;			//小费(元)
	int nIgoreOverTime;			//一个计时单位内可以忽略的计费时长(分钟)
	int iIgoreTime;				//总时长小于这个则不收费(分)
	
	SimpleDateFormat sdf = new SimpleDateFormat("hh:mm");
	
	public ParkOrderExt(){}
	
	public static ParkOrderExt newInstance(String jsonString){
		JSONObject json = JSONObject.fromObject(jsonString);
		ParkOrderExt poe = null;
		if(json!=null){
			poe = (ParkOrderExt) JSONObject.toBean(json, ParkOrderExt.class);
			if(poe!=null){
				// to do some check
			}
			return poe;
		}
		return null;
	}
	@Override
	public String toString(){
		return JSONObject.fromObject(this).toString();
	}
	
	public static void main(String[] argv){
		String jsonString="{\"dayStartTime\":\"9:00\",\"dayEndTime\":\"17:00\",\"dayPrice\":0.03,\"dayTimeUnit\":1, \"nightStartTime\":\"20:00\",\"nightEndTime\":\"6:00\",\"nightPrice\":0,\"nightTimeUnit\":1}";
		ParkOrderExt p = ParkOrderExt.newInstance(jsonString);
		System.out.println(p.getDayStartTime());
		System.out.println(p.toString());
	}
	
	
	public ParkOrderExt(String dayStartTime, String dayEndTime,
			String nightStartTime, String nightEndTime, float dayTimeUnit,
			float nightTimeUnit, float dayPrice, float nightPrice) {
		super();
		this.dayStartTime = dayStartTime;
		this.dayEndTime = dayEndTime;
		this.nightStartTime = nightStartTime;
		this.nightEndTime = nightEndTime;
		this.dayTimeUnit = dayTimeUnit;
		this.nightTimeUnit = nightTimeUnit;
		this.dayPrice = dayPrice;
		this.nightPrice = nightPrice;
	}


	/**
	 * @return the dayStartTime
	 */
	public String getDayStartTime() {
		return dayStartTime;
	}


	/**
	 * @param dayStartTime the dayStartTime to set
	 */
	public void setDayStartTime(String dayStartTime) {
		this.dayStartTime = dayStartTime;
		if(dayStartTime!=null){
			try {
				Date time = sdf.parse(dayStartTime);
				if(time!=null){
					this.setUcDayStartHour( time.getHours() );
					this.setUcDayStartMinute(time.getMinutes());
				}
			} catch (ParseException e) {
				e.printStackTrace();
			}
		}
		
	}


	/**
	 * @return the dayEndTime
	 */
	public String getDayEndTime() {
		return dayEndTime;
	}


	/**
	 * @param dayEndTime the dayEndTime to set
	 */
	public void setDayEndTime(String dayEndTime) {
		this.dayEndTime = dayEndTime;
		if(dayEndTime!=null){
			try {
				Date time = sdf.parse(dayEndTime);
				if(time!=null){
					this.setUcDayStopHour( time.getHours() );
					this.setUcDayStopMinute(time.getMinutes());
				}
			} catch (ParseException e) {
				e.printStackTrace();
			}
		}
	}


	/**
	 * @return the nightStartTime
	 */
	public String getNightStartTime() {
		return nightStartTime;
	}


	/**
	 * @param nightStartTime the nightStartTime to set
	 */
	public void setNightStartTime(String nightStartTime) {
		this.nightStartTime = nightStartTime;
		if(nightStartTime!=null){
			try {
				Date time = sdf.parse(nightStartTime);
				if(time!=null){
					this.setUcNightStartHour( time.getHours() );
					this.setUcNightStartMinute(time.getMinutes());
				}
			} catch (ParseException e) {
				e.printStackTrace();
			}
		}
	}

	/**
	 * @return the nightEndTime
	 */
	public String getNightEndTime() {
		return nightEndTime;
	}


	/**
	 * @param nightEndTime the nightEndTime to set
	 */
	public void setNightEndTime(String nightEndTime) {
		this.nightEndTime = nightEndTime;
		if(nightEndTime!=null){
			try {
				Date time = sdf.parse(nightEndTime);
				if(time!=null){
					this.setUcNightStopHour( time.getHours() );
					this.setUcNightStopMinute(time.getMinutes());
				}
			} catch (ParseException e) {
				e.printStackTrace();
			}
		}
	}


	/**
	 * @return the dayTimeUnit
	 */
	public double getDayTimeUnit() {
		return dayTimeUnit;
	}


	/**
	 * @param dayTimeUnit the dayTimeUnit to set
	 */
	public void setDayTimeUnit(double dayTimeUnit) {
		this.dayTimeUnit = dayTimeUnit;
	}


	/**
	 * @return the nightTimeUnit
	 */
	public double getNightTimeUnit() {
		return nightTimeUnit;
	}


	/**
	 * @param nightTimeUnit the nightTimeUnit to set
	 */
	public void setNightTimeUnit(double nightTimeUnit) {
		this.nightTimeUnit = nightTimeUnit;
	}


	/**
	 * @return the dayPrice
	 */
	public double getDayPrice() {
		return dayPrice;
	}


	/**
	 * @param dayPrice the dayPrice to set
	 */
	public void setDayPrice(double dayPrice) {
		this.dayPrice = dayPrice;
	}


	/**
	 * @return the nightPrice
	 */
	public double getNightPrice() {
		return nightPrice;
	}


	/**
	 * @param nightPrice the nightPrice to set
	 */
	public void setNightPrice(float nightPrice) {
		this.nightPrice = nightPrice;
	}

	public int getUcDayStartHour() {
		return ucDayStartHour;
	}

	public void setUcDayStartHour(int ucDayStartHour) {
		this.ucDayStartHour = ucDayStartHour;
	}

	public int getUcDayStartMinute() {
		return ucDayStartMinute;
	}

	public void setUcDayStartMinute(int ucDayStartMinute) {
		this.ucDayStartMinute = ucDayStartMinute;
	}

	public int getUcDayStopHour() {
		return ucDayStopHour;
	}

	public void setUcDayStopHour(int ucDayStopHour) {
		this.ucDayStopHour = ucDayStopHour;
	}

	public int getUcDayStopMinute() {
		return ucDayStopMinute;
	}

	public void setUcDayStopMinute(int ucDayStopMinute) {
		this.ucDayStopMinute = ucDayStopMinute;
	}

	public int getUcNightStartHour() {
		return ucNightStartHour;
	}

	public void setUcNightStartHour(int ucNightStartHour) {
		this.ucNightStartHour = ucNightStartHour;
	}

	public int getUcNightStartMinute() {
		return ucNightStartMinute;
	}

	public void setUcNightStartMinute(int ucNightStartMinute) {
		this.ucNightStartMinute = ucNightStartMinute;
	}

	public int getUcNightStopHour() {
		return ucNightStopHour;
	}

	public void setUcNightStopHour(int ucNightStopHour) {
		this.ucNightStopHour = ucNightStopHour;
	}

	public int getUcNightStopMinute() {
		return ucNightStopMinute;
	}

	public void setUcNightStopMinute(int ucNightStopMinute) {
		this.ucNightStopMinute = ucNightStopMinute;
	}


	public double getnGratuity() {
		return nGratuity;
	}

	public void setnGratuity(double nGratuity) {
		this.nGratuity = nGratuity;
	}

	public int getnIgoreOverTime() {
		return nIgoreOverTime;
	}

	public void setnIgoreOverTime(int nIgoreOverTime) {
		this.nIgoreOverTime = nIgoreOverTime;
	}

	public int getiIgoreTime() {
		return iIgoreTime;
	}

	public void setiIgoreTime(int iIgoreTime) {
		this.iIgoreTime = iIgoreTime;
	}	
}
